package com.winsdom.context;

public class BaseContext {

    // 当前 ID 的 ThreadLocal 实例
    private static final ThreadLocal<Integer> CURRENT_ID_LOCAL = new ThreadLocal<>();

    // 分类 ID 的 ThreadLocal 实例
    private static final ThreadLocal<Integer> CATEGORY_ID_LOCAL = new ThreadLocal<>();

    /**
     * 设置当前 ID
     *
     * @param id 当前 ID
     */
    public static void setCurrentId(Integer id) {
        CURRENT_ID_LOCAL.set(id);
    }

    /**
     * 获取当前 ID
     *
     * @return 当前 ID
     */
    public static Integer getCurrentId() {
        return CURRENT_ID_LOCAL.get();
    }

    /**
     * 移除当前 ID
     */
    public static void removeCurrentId() {
        CURRENT_ID_LOCAL.remove();
    }

    /**
     * 设置分类 ID
     *
     * @param categoryId 分类 ID
     */
    public static void setCategoryId(Integer categoryId) {
        CATEGORY_ID_LOCAL.set(categoryId);
    }

    /**
     * 获取分类 ID
     *
     * @return 分类 ID
     */
    public static Integer getCategoryId() {
        return CATEGORY_ID_LOCAL.get();
    }

    /**
     * 移除分类 ID
     */
    public static void removeCategoryId() {
        CATEGORY_ID_LOCAL.remove();
    }
}